// test_script.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

int log_err(const char* msg)
{
	printf("Error: %s\n", msg);
	return 1;
}

int log_err(const char* msg, DWORD code)
{
	printf("Error: %s(0x%.08lX)\n", msg, code);
	return code;
}

int log_sys_err(const char* msg)
{
	printf("Sys.error: %s(0x%.08lX)\n", msg, ::GetLastError());
	return 1;
}

#define CHECK_RET(cond) \
	if (!(cond)) \
		return log_err(#cond)

#define CHECK_SYS_RET(cond) \
	if (!(cond)) \
		return log_sys_err(#cond)


typedef int (*FntypeSetWindbgInterface)(bool setValid);
typedef int (*FntypeRunPerl)(const char* file);

int _tmain(int argc, _TCHAR* argv[])
{
	HMODULE grayext = LoadLibraryW(L"se.dll");
	CHECK_SYS_RET(grayext != NULL);

	FntypeRunPerl runPerl = reinterpret_cast<FntypeRunPerl>(GetProcAddress(grayext, "RunPerl"));
	CHECK_SYS_RET(runPerl != NULL);

	runPerl("test.pl");

	return 0;
}

